luci-mod-network: clean up btn1 and btn2 disable
authorFlorian Eckert <[email protected]>
Tue, 7 Oct 2025 08:42:19 +0000 (10:42 +0200)
committerFlorian Eckert <[email protected]>
Fri, 10 Oct 2025 12:08:20 +0000 (14:08 +0200)
In the current source, it is difficult to see when the disable button
should be shown or not. This commit adjusts this and moves the handling
to an if else statement, so that it can be easily seen.

Signed-off-by: Florian Eckert <[email protected]>
modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js

index f7e092e49abe8a5793805ee2d195ba8e07c8662d..3574115d3cb18b9ea5ec3faf38c2d563c26b93e8 100644 (file)
@@ -305,8 +305,26 @@ return view.extend({
                                ]);
                        }
 
-                       btn1.disabled = isReadonlyView || btn1.classList.contains('spinning') || btn2.classList.contains('spinning') || dynamic;
-                       btn2.disabled = isReadonlyView || btn1.classList.contains('spinning') || btn2.classList.contains('spinning') || dynamic || disabled;
+                       if (isReadonlyView === true) {
+                               btn1.disabled = true;
+                               btn2.disabled = true;
+                       }
+                       else if (btn1.classList.contains('spinning') || btn2.classList.contains('spinning')) {
+                               btn1.disabled = true;
+                               btn2.disabled = true;
+                       }
+                       else if (dynamic === true) {
+                               btn1.disabled = true;
+                               btn2.disabled = true;
+                       }
+                       else if (disabled === true) {
+                               btn1.disabled = false;
+                               btn2.disabled = true;
+                       }
+                       else {
+                               btn1.disabled = false;
+                               btn2.disabled = false;
+                       }
                }
 
                document.querySelectorAll('.port-status-device[data-device]').forEach(function(node) {